package top.zhan.strategy;

/**
 * @author Zhan
 * @date 2022/10/6 10:34
 */
public class VoucherActivity extends Strategy{

    /**
     * 传入优惠券
     */
    private double voucher;

    public VoucherActivity(double voucher){
        this.voucher = voucher;
    }

    @Override
    public double computePrice(ProductOrder productOrder) {
        if(productOrder.getOldPrice() > voucher){
            return productOrder.getOldPrice() - voucher;
        } else {
            return 0;
        }
    }
}
